package com.xms.plugin.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.xms.datacore.service.DeleterService;
import com.xms.plugin.entity.EntityPlugin;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.SQLException;
import java.util.Collection;
import java.util.UUID;

/**
 * <p>
 * EntityPluginDeleterService
 * </p>
 *
 * @author migo
 * @since 2021/10/15
 */
@CacheConfig(cacheNames = "entityplugin", keyGenerator = "CacheKeyGenerator")
@Service
public class EntityPluginDeleterService extends DeleterService<EntityPlugin> implements IEntityPluginDeleterService {

    @CacheEvict(allEntries = true, condition = "#result == true")
    @Transactional(rollbackFor=Exception.class)
    @Override
    public boolean deleteById(UUID id) throws SQLException {
        return super.removeById(id);
    }

    @CacheEvict(allEntries = true, condition = "#result == true")
    @Transactional(rollbackFor=Exception.class)
    @Override
    public boolean deleteMany(Wrapper<EntityPlugin> queryWrapper) throws SQLException {
        return super.remove(queryWrapper);
    }

    @CacheEvict(allEntries = true, condition = "#result == true")
    @Transactional(rollbackFor=Exception.class)
    @Override
    public boolean deleteByIds(Collection<UUID> idList) throws SQLException {
        return super.removeByIds(idList);
    }
}
